package tyk.statement;

import com.mysql.cj.jdbc.Driver;

import java.sql.*;
import java.util.Scanner;

/***
 *@title StatementUserLoginPart
 *@description <TODO description class purpose>
 *@author Tang'ya'kang
 *@VERSION 1.0.0
 *@CREATE 2023/5/3 18:56
 **/
public class StatementUserLoginPart {
    public static void main(String[] args) throws SQLException {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入账号");
        String account=scanner.nextLine();
        System.out.println("请输入密码");
        String password=scanner.nextLine();
        new Driver();
        Connection connection= DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/javaweb","root","123456");
        Statement statement=connection.createStatement();
        String sql="select *  from t_user where account = '"+account+"' and password = '"+password+"';";
        ResultSet resultSet=statement.executeQuery(sql);
        if(resultSet.next()) System.out.println("登录成功");
        else System.out.println("密码或账号错误");
    }
}
